package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerPlanEffort;
import com.shrcl.engineerprocess.domain.EngineerProject;
import com.shrcl.engineerprocess.domain.EngineerProjectPlan;
import com.shrcl.engineerprocess.domain.impl.EngineerPlanEffortImpl;
import com.shrcl.engineerprocess.domain.impl.EngineerProjectImpl;
import com.shrcl.engineerprocess.domain.proxy.EngineerProjectPlanProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("ENGINEERPROJECTPLAN_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "engineerprojectplan")
public class EngineerProjectPlanImpl extends BaseModelObject implements EngineerProjectPlan {
  public EngineerProjectPlanImpl() {
    super();
  }
  
  @JoinColumn(name = "engineerProject_id")
  @ManyToOne(targetEntity = EngineerProjectImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private EngineerProject engineerProject;
  
  public EngineerProject getEngineerProject() {
    return this.engineerProject;
  }
  
  public EngineerProjectPlan setEngineerProject(final EngineerProject engineerProject) {
    this.engineerProject = engineerProject;
    return this;			
    
  }
  
  private Date startDate;
  
  public Date getStartDate() {
    return this.startDate;
  }
  
  public EngineerProjectPlan setStartDate(final Date startDate) {
    this.startDate = startDate;
    return this;			
    
  }
  
  private Date startTime;
  
  public Date getStartTime() {
    return this.startTime;
  }
  
  public EngineerProjectPlan setStartTime(final Date startTime) {
    this.startTime = startTime;
    return this;			
    
  }
  
  private Date endDate;
  
  public Date getEndDate() {
    return this.endDate;
  }
  
  public EngineerProjectPlan setEndDate(final Date endDate) {
    this.endDate = endDate;
    return this;			
    
  }
  
  private Date endTime;
  
  public Date getEndTime() {
    return this.endTime;
  }
  
  public EngineerProjectPlan setEndTime(final Date endTime) {
    this.endTime = endTime;
    return this;			
    
  }
  
  private String workName;
  
  public String getWorkName() {
    return this.workName;
  }
  
  public EngineerProjectPlan setWorkName(final String workName) {
    this.workName = workName;
    return this;			
    
  }
  
  @OneToMany(targetEntity = EngineerPlanEffortImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE }, mappedBy = "engineerProjectPlan")
  private Collection<EngineerPlanEffort> efforts = new java.util.ArrayList<com.shrcl.engineerprocess.domain.EngineerPlanEffort>();;
  
  public Collection<EngineerPlanEffort> getEfforts() {
    return this.efforts;
  }
  
  public EngineerPlanEffort createAndAddtoEfforts() {
    getEfforts().size();
    com.shrcl.engineerprocess.domain.EngineerPlanEffort engineerPlanEffort = new com.shrcl.engineerprocess.domain.impl.EngineerPlanEffortImpl(this);
    getObjectFactory().create(engineerPlanEffort);
    getEfforts().add(engineerPlanEffort);
    return engineerPlanEffort;
    
  }
  
  public EngineerPlanEffort createAndAddtoEfforts(final Procedure1<EngineerPlanEffort> updater) {
    getEfforts().size();
    com.shrcl.engineerprocess.domain.EngineerPlanEffort engineerPlanEffort = new com.shrcl.engineerprocess.domain.impl.EngineerPlanEffortImpl(this);
    getObjectFactory().create(engineerPlanEffort);
    getEfforts().add(engineerPlanEffort);
    return engineerPlanEffort;
    
  }
  
  public EngineerProjectPlan removeAllEfforts() {
    for(EngineerPlanEffort obj : this.efforts){
    	getObjectFactory().delete(obj);
    }
    this.efforts.clear();
    return this;	
    
  }
  
  public EngineerProjectPlan removeFromEfforts(final EngineerPlanEffort engineerPlanEffort) {
    this.efforts.remove(engineerPlanEffort);
    getObjectFactory().delete(engineerPlanEffort);
    return this;
    
  }
  
  public static EngineerProjectPlan create(final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.EngineerProjectPlan engineerProjectPlan = new com.shrcl.engineerprocess.domain.impl.EngineerProjectPlanImpl(
    );
    objectFactory.create(engineerProjectPlan);
    return engineerProjectPlan;			
    
  }
  
  public static EngineerProjectPlan createEngineerProjectPlanImpl(final IObjectFactory objectFactory, final Procedure1<EngineerProjectPlan> init) {
    com.shrcl.engineerprocess.domain.EngineerProjectPlan engineerProjectPlan = new com.shrcl.engineerprocess.domain.impl.EngineerProjectPlanImpl(
    );
    objectFactory.create(engineerProjectPlan);
    init.apply(engineerProjectPlan);
    
    return engineerProjectPlan;			
    
  }
  
  public EngineerProjectPlanProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.EngineerProjectPlanProxy proxy = new com.shrcl.engineerprocess.domain.proxy.EngineerProjectPlanProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
